package day10;

/**
 * @author oldliu
 * @since 1.0
 */
public class Thread4 extends Thread {
    public Thread4(String n){
        super(n);
    }

    @Override
    public void run() {
        while (true) {
            System.out.printf("工人%s开始干活了，干了一会，睡觉\n", this.getName());
            try {
                sleep(500);
                System.out.printf("工人%s睡到自然醒，继续干活\n", this.getName());
            } catch (InterruptedException e) {
                System.out.printf("工人%s被喊醒，继续干活\n", this.getName());
                e.printStackTrace();
            }
        }
    }
}
